﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Acando.Dynamics.CRM.Silverlight.Library.Interfaces;
using Acando.Dynamics.CRM.Silverlight.Library.Dialogs;
using Acando.Dynamics.CRM.Silverlight.Library.CrmSdk;
using System.IO.IsolatedStorage;

namespace Acando.Dynamics.CRM.Silverlight.Library.Helper
{

    public class ApplicationContext
    {
        #region Singleton

        static ApplicationContext()
        {
            Current = new ApplicationContext();
        }

        public static ApplicationContext Current
        {
            get;
            private set;
        }

        private ApplicationContext()
        {

        }

        #endregion


        #region Init

        public event EventHandler InitCompleted;

        public void InitContext()
        {
            //LoginDialog login = new LoginDialog();
            //login.DialogClosed += new EventHandler(login_DialogClosed);
            //login.ShowDialog();
        }

        void login_DialogClosed(object sender, EventArgs e)
        {
            this.InitCompleted(sender, e);
        }


        #endregion

        
        public Guid GetCurrentUserId()
        {
            return Guid.Empty;
        }

        public int GetUserLanguage()
        {
            return 1031;
        }

        public Panel GetParentForDialogs()
        {
            if (Application.Current.RootVisual is IPage)
                return (Application.Current.RootVisual as IPage).ParentElementForDialogs;
            else
                throw new Exception("Page must implement IPage interface");
        }

    }
}
